/*
 * Copyright © 2022 XXXXXXXXX
 * @Author: zhangxiang
 * @Date: 2022-08-05 14:45:50
 * @LastEditors: zhangxiang
 * @LastEditTime: 2023-09-21 16:03:02
 * @Description: 集群管理 相关接口
 * 来源：调度平台cnap-V2.1 混合算网管理
 * 前缀 /cnap/cnap
 *
 */

import request from '@/utils/request'

const PREFIX = '/cnap'

/**
 * @description: 获取云商
 * @param {*} params
 * @return {*}
 */
export function getAllCloudVendor(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/getAllCloudVendorInfo',
    method: 'get',
    params
  })
}

/**
 * @description: 根据条件获取集群列表
 * @param {*} params
 * @return {*}
 */
export function getK8sClusterInfos(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/multiCloud/getK8sClusterInfos',
    method: 'get',
    params
  })
}

/**
 * @description: 注册集群
 * @param {*} data
 * @return {*}
 */
export function addK8sCluster(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/multiCloud/addK8sClusterByToken',
    method: 'post',
    data
  })
}

/**
 * @description: 创建集群
 * @param {*} data
 * @return {*}
 */
export function vmAddK8sCluster(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/multiCloud/vmAddK8sCluster',
    method: 'post',
    data
  })
}

/**
 * @description: 编辑集群
 * @param {*} data
 * @return {*}
 */
export function editK8sClusterInfo(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/multiCloud/editK8sClusterInfo',
    method: 'put',
    data
  })
}

/**
 * @description: 删除集群
 * @param {*} params
 * @return {*}
 */
export function deleteK8sClusterInfo(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/multiCloud/editK8sClusterInfo',
    method: 'delete',
    params
  })
}

/**
 * @description: 根据条件获取node节点列表
 * @param {*} params
 * @return {*}
 */
export function getK8sClusterNodeInfos(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/getK8sClusterNodeInfos',
    method: 'get',
    params
  })
}

/**
 * @description: 编辑节点
 * @param {*} data
 * @return {*}
 */
export function editK8sClusterNodeInfo(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/editK8sClusterNodeInfo',
    method: 'put',
    data
  })
}

/**
 * @description: 获取集群master节点数目
 * @param {*} params
 * @return {*}
 */
export function getK8sClusterMasterNodeNum(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/getK8sClusterMasterNodeNum',
    method: 'get',
    params
  })
}

/**
 * @description: 删除节点
 * @param {*} params
 * @return {*}
 */
export function deleteK8sClusterNodeInfo(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/editK8sClusterNodeInfo',
    method: 'delete',
    params
  })
}

/**
 * @description: 新增节点
 * @param {*} params
 * @return {*}
 */
export function addK8sClusterNodeInfo(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/addK8sClusterNode',
    method: 'post',
    data
  })
}

/**
 * @description: 根据条件获取namespace列表
 * @param {*} params
 * @return {*}
 */
export function getK8sClusterNameSpaces(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/getK8sClusterNameSpaces',
    method: 'get',
    params
  })
}

/**
 * @description: 创建namespace
 * @param {*} data
 * @return {*}
 */
export function addK8sClusterNameSpaces(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/addK8sClusterNameSpaces',
    method: 'post',
    data
  })
}

/**
 * @description: 删除namespace
 * @param {*} params
 * @return {*}
 */
export function delK8sClusterNameSpaces(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/delK8sClusterNameSpaces',
    method: 'delete',
    params
  })
}

/**
 * @description: 根据条件获取工作负载列表
 * @param {*} params
 * @return {*}
 */
export function getK8sClusterWorkLoads(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/getK8sClusterWorkLoads',
    method: 'get',
    params
  })
}

/**
 * @description: 创建工作负载
 * @param {*} data
 * @return {*}
 */
export function addK8sClusterWorkLoads(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/addK8sClusterWorkLoad',
    method: 'post',
    data
  })
}

/**
 * @description: 删除工作负载
 * @param {*} params
 * @return {*}
 */
export function delK8sClusterWorkLoad(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/delK8sClusterWorkLoad',
    method: 'delete',
    params
  })
}

/**
 * @description: 工作负载更新镜像
 * @param {*} data
 * @return {*}
 */
export function editK8sClusterWorkLoadContainers(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/editK8sClusterWorkLoadContainers',
    method: 'put',
    data
  })
}

/**
 * @description: 工作负载扩缩容
 * @param {*} data
 * @return {*}
 */
export function editK8sClusterWorkLoadReplicas(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/editK8sClusterWorkLoadReplicas',
    method: 'put',
    data
  })
}
/**
 * @description: 工作负载更新yaml
 * @param {*} data
 * @return {*}
 */
export function editK8sClusterWorkLoadYaml(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/editK8sClusterWorkLoadYaml',
    method: 'put',
    data
  })
}

/**
 * @description: 根据条件获取容器组列表
 * @param {*} params
 * @return {*}
 */
export function getK8sClusterPods(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/getK8sClusterPods',
    method: 'get',
    params
  })
}

/**
 * @description: 根据条件获取具体容器
 * @param {*} params
 * @return {*}
 */
export function getK8sClusterPodContainers(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/getK8sClusterPodContainers',
    method: 'get',
    params
  })
}

/**
 * @description: 删除容器组
 * @param {*} params
 * @return {*}
 */
export function delK8sClusterPod(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/delK8sClusterPod',
    method: 'delete',
    params
  })
}

/**
 * @description: 根据条件获取服务
 * @param {*} params
 * @return {*}
 */
export function getK8sClusterSvcs(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/getK8sClusterSvcs',
    method: 'get',
    params
  })
}

/**
 * @description: 新建服务
 * @param {*} data
 * @return {*}
 */
export function addK8sClusterSvc(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/addK8sClusterSvc',
    method: 'post',
    data
  })
}

/**
 * @description: 编辑服务
 * @param {*} data
 * @return {*}
 */
export function editK8sClusterSvc(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/editK8sClusterSvc',
    method: 'post',
    data
  })
}

/**
 * @description: 删除服务
 * @param {*} params
 * @return {*}
 */
export function delK8sClusterSvc(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/k8sCluster/delK8sClusterSvc',
    method: 'delete',
    params
  })
}

/**
 * @description: 查询伸缩组列表
 * @param {*} params
 * @return {*}
 */
export function getScalingGroupList(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/scaling/group/list',
    method: 'post',
    data
  })
}

/**
 * @description: 创建伸缩组
 * @param {*} data
 * @return {*}
 */
export function addScalingGroup(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/scaling/group/add',
    method: 'post',
    data
  })
}

/**
 * @description: 删除伸缩组
 * @param {*} groupId
 * @return {*}
 */
export function deleteScalingGroup(groupId) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/scaling/group/delete/' + groupId,
    method: 'delete'
  })
}

/**
 * @description: 启用伸缩组策略
 * @param {*} groupId
 * @return {*}
 */
export function startScalingGroup(groupId) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/scaling/group/start/' + groupId,
    method: 'get'
  })
}

/**
 * @description: 停用伸缩组策略
 * @param {*} groupId
 * @return {*}
 */
export function stopScalingGroup(groupId) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/scaling/group/stop/' + groupId,
    method: 'get'
  })
}

/**
 * @description: 创建伸缩策略
 * @param {*} data
 * @return {*}
 */
export function addScalingPolicy(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/scaling/policy/add',
    method: 'post',
    data
  })
}

/**
 * @description: 查询伸缩配置列表
 * @param {*} data
 * @return {*}
 */
export function getScalingConfigList(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/scaling/config/list',
    method: 'post',
    data
  })
}

/**
 * @description: 根据vpcId查询伸缩配置
 * @param {*} params
 * @return {*}
 */
export function getScalingConfigByVPCId(vpcId) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/scaling/config/vpcId/' + vpcId,
    method: 'get'
  })
}

/**
 * @description: 删除伸缩配置
 * @param {*} deleteId
 * @return {*}
 */
export function deleteScalingConfig(deleteId) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/scaling/config/delete/' + deleteId,
    method: 'delete'
  })
}

/**
 * @description: 创建伸缩配置
 * @param {*} data
 * @return {*}
 */
export function addScalingConfig(data) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/scaling/config/add',
    method: 'post',
    data
  })
}

/**
 * @description: 获取伸缩配置推荐规格
 * @param {*} params
 * @return {*}
 */
export function getScalingResourceAll(params) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/scaling/resource/all',
    method: 'get',
    params
  })
}

/**
 * @description: 根据id查询伸缩配置推荐规格
 * @param {*} params
 * @return {*}
 */
export function getScalingResourceById(id) {
  return request({
    url: PREFIX + '/cnap/multicloudmgmt/v1/scaling/resource/' + id,
    method: 'get'
  })
}
